lasio uses the logging module to log warnings and other information when manipulating LAS files.


In [1]:
import logging
import lasio

Sometimes you may want more or less information shown to you when you are reading LAS files with lasio.

By default the logging level is set to WARNING, so you will only see a certain class of messages:


In [2]:
l = lasio.read('../tests/examples/logging_levels.las')


Header section Parameter regexp=~P was not found.

As you can see, the logger shows a warning that the Parmeter section was not found in the LAS file.

To get more information when loading a file, you can set the logging level to INFO. First, instantiate the root logger with a basic configuration:


In [3]:
logging.basicConfig()

Then get the lasio logger object and set the logging level to INFO:


In [4]:
logger = logging.getLogger(lasio.__name__)
logger.setLevel(logging.INFO)

l = lasio.read('../tests/examples/logging_levels.las')


INFO:lasio.reader:Opening ../tests/examples/logging_levels.las as ascii and treating errors with "replace"
WARNING:lasio.las:Header section Parameter regexp=~P was not found.

To get even more information, you can set the logging level to DEBUG:


In [5]:
logger.setLevel(logging.DEBUG)

l = lasio.read('../tests/examples/logging_levels.las')


DEBUG:lasio.reader:get_encoding Using chardet
DEBUG:lasio.reader:chardet method detected encoding of ascii at confidence 1.0
INFO:lasio.reader:Opening ../tests/examples/logging_levels.las as ascii and treating errors with "replace"
DEBUG:lasio.reader:using read policy of "default"
DEBUG:lasio.reader:adding substitution comma-decimal-mark
DEBUG:lasio.reader:adding substitution run-on(-)
DEBUG:lasio.reader:adding substitution run-on(.)
DEBUG:lasio.reader:adding substitution run-on(NaN.)
DEBUG:lasio.reader:added regexp substitution: pattern=re.compile('(\\d),(\\d)') substr="\1.\2"
DEBUG:lasio.reader:added regexp substitution: pattern=re.compile('(\\d)-(\\d)') substr="\1 -\2"
DEBUG:lasio.reader:added regexp substitution: pattern=re.compile('-?\\d*\\.\\d*\\.\\d*') substr=" NaN NaN "
DEBUG:lasio.reader:added regexp substitution: pattern=re.compile('NaN[\\.-]\\d+') substr=" NaN NaN "
DEBUG:lasio.reader:using null policy of "common"
DEBUG:lasio.reader:adding substitution NULL
DEBUG:lasio.reader:located substition for LAS.version.NULL as True
DEBUG:lasio.reader:adding substitution (null)
DEBUG:lasio.reader:adding substitution -
DEBUG:lasio.reader:adding substitution 9999.25
DEBUG:lasio.reader:adding substitution 999.25
DEBUG:lasio.reader:adding substitution NA
DEBUG:lasio.reader:adding substitution INF
DEBUG:lasio.reader:adding substitution IO
DEBUG:lasio.reader:adding substitution IND
DEBUG:lasio.reader:added numerical substitution: None
DEBUG:lasio.reader:added regexp substitution: pattern=re.compile(' \\(null\\)') substr=" NaN"
DEBUG:lasio.reader:added regexp substitution: pattern=re.compile('\\(null\\) ') substr="NaN "
DEBUG:lasio.reader:added regexp substitution: pattern=re.compile(' \\(NULL\\)') substr=" NaN"
DEBUG:lasio.reader:added regexp substitution: pattern=re.compile('\\(NULL\\) ') substr="NaN "
DEBUG:lasio.reader:added regexp substitution: pattern=re.compile(' null') substr=" NaN"
DEBUG:lasio.reader:added regexp substitution: pattern=re.compile('null ') substr="NaN "
DEBUG:lasio.reader:added regexp substitution: pattern=re.compile(' NULL') substr=" NaN"
DEBUG:lasio.reader:added regexp substitution: pattern=re.compile('NULL ') substr="NaN "
DEBUG:lasio.reader:added regexp substitution: pattern=re.compile(' -+ ') substr=" NaN "
DEBUG:lasio.reader:added numerical substitution: -9999.25
DEBUG:lasio.reader:added numerical substitution: 9999.25
DEBUG:lasio.reader:added numerical substitution: -999.25
DEBUG:lasio.reader:added numerical substitution: 999.25
DEBUG:lasio.reader:added regexp substitution: pattern=re.compile('(#N/A)[ ]') substr="NaN "
DEBUG:lasio.reader:added regexp substitution: pattern=re.compile('[ ](#N/A)') substr=" NaN"
DEBUG:lasio.reader:added regexp substitution: pattern=re.compile('(-?1\\.#INF)[ ]') substr="NaN "
DEBUG:lasio.reader:added regexp substitution: pattern=re.compile('[ ](-?1\\.#INF[0-9]*)') substr=" NaN"
DEBUG:lasio.reader:added regexp substitution: pattern=re.compile('(-?1\\.#IO)[ ]') substr="NaN "
DEBUG:lasio.reader:added regexp substitution: pattern=re.compile('[ ](-?1\\.#IO)') substr=" NaN"
DEBUG:lasio.reader:added regexp substitution: pattern=re.compile('(-?1\\.#IND)[ ]') substr="NaN "
DEBUG:lasio.reader:added regexp substitution: pattern=re.compile('[ ](-?1\\.#IND[0-9]*)') substr=" NaN"
DEBUG:lasio.reader:Data section ["array"].shape = (523710,)
WARNING:lasio.las:Header section Parameter regexp=~P was not found.
DEBUG:lasio.las:~A data.shape (523710,)
DEBUG:lasio.las:~A after NULL replacement data.shape (523710,)
DEBUG:lasio.las:n_curves=18 ncols=18
DEBUG:lasio.las:set_data data.shape = (29095, 18)
DEBUG:lasio.las:set_data self.data.shape = (29095, 18)

One strategy for suppressing logging messages is to set the logger level to a very high level, such that only messages with a CRITICAL designation are shown:


In [6]:
logger.setLevel(logging.CRITICAL)

l = lasio.read('../tests/examples/logging_levels.las')

In that case, no messages were logged since no CRITICAL level issues were encountered.

Just to prove that the LAS file loaded, even though no messages were shown, here's a header item:


In [7]:
l.header['Well'].SRVC


Out[7]:
HeaderItem(mnemonic=SRVC, unit=, value=Baker Hughes Inc., descr=Service, original_mnemonic=SRVC)